package com.mapproject.industrymap.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mapproject.industrymap.service.GeoserverRequestInfoService;
import com.mapproject.industrymap.utils.ReturnValue;
import com.mapproject.industrymap.utils.XmlConverUtil;
import org.springframework.stereotype.Service;

@Service
public class GeoserverRequestInfoServiceImpl implements GeoserverRequestInfoService {
    @Override
    public ReturnValue getStyle(String layername) {
        try {
            XmlConverUtil xmlConverUtil=new XmlConverUtil();
            String xmlStr = xmlConverUtil.readFile(layername);
            String ret= xmlConverUtil.XmlToJson(xmlStr);
            ret=  ret.replaceAll("se:","");
            ret=  ret.replaceAll("ogc:","");
            JSONObject jsonObj =xmlConverUtil.jsonLoop(JSON.parseObject(ret) ) ;
            return new ReturnValue(200,"", jsonObj);
        } catch (Exception e) {
            e.printStackTrace();
            return new ReturnValue(500,"错误xml");
        }


    }


}
